import java.util.Scanner;

public class test1 {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);

        while (true) {
            System.out.println("请输入年份和月份,-1退出");
            String str = scan.next();
            if (str.equals("-1")) {
                break;
            }
            String stryear = str.substring(0, 4);
            String strmonth = str.substring(5, 7);

            int year = Integer.parseInt(stryear);
            int month = Integer.parseInt(strmonth);

            int day = getDay(year,month);
            System.out.println(day);
        }

    }

    public static int getDay(int year,int month){
        int day = 0;
        switch (month) {
            case 1:
                day = 31;
                break;
            case 2:
                day = 28;
                break;
            case 3:
                day = 31;
                break;
            case 4:
                day = 30;
                break;
            case 5:
                day = 31;
                break;
            case 6:
                day = 30;
                break;
            case 7:
                day = 31;
                break;
            case 8:
                day = 31;
                break;
            case 9:
                day = 30;
                break;
            case 10:
                day = 31;
                break;
            case 11:
                day = 30;
                break;
            case 12:
                day = 31;
                break;
            default:
                System.out.println("没有这个月份");
                System.exit(0);
        }

        if (((year % 4 == 0 && year % 100 != 0) || year % 400 == 0) && month == 2) {
            return day + 1;

        } else {
            return day;

        }
    }

}
